package com.qf.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.qf.constans.ResultCode;

/*
杨威
2021/10/25
20:35
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class R {
    private int code;//状态码
    private String msg;//状态码描述
    private Object data;//返回的当前数据

    public static R setOk(){
        return setOk(null);
    }
    public static R setOk(Object data){
        R r=new R();
        r.setCode(ResultCode.SUCCESS);
        r.setMsg("成功");
        r.setData(data);
        return r;
    }

    public static R setError(){
        return setError(null);
    }
    public static R setError(Object data){
        R r=new R();
        r.setCode(ResultCode.FAIL);
        r.setMsg("失败");
        r.setData(data);
        return r;
    }
    public static R setError(int code,String msg,Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
